var map,mposctl,vectors, geojson,markers,selectControl;
var selectedFeature;
//Init
map = new OpenLayers.Map('floor2');
layer = new OpenLayers.Layer.Image(
    "floor2",
    "floor2.jpg",
    new OpenLayers.Bounds(-1097,-270.5,1097,270.5),
    new OpenLayers.Size(2194,541)
);
map.addLayer(layer);
map.zoomToMaxExtent();
var featurecollection = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_92",
            "properties": {
                "name": "A.202",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1077,
                            249
                        ],
                        [
                            -803,
                            248
                        ],
                        [
                            -801,
                            34
                        ],
                        [
                            -1078,
                            35
                        ],
                        [
                            -1077,
                            249
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_114",
            "properties": {
                "name": "A.202",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1078,
                            27
                        ],
                        [
                            -803,
                            30
                        ],
                        [
                            -803,
                            -185
                        ],
                        [
                            -1078,
                            -186
                        ],
                        [
                            -1078,
                            27
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_136",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -685,
                            248
                        ],
                        [
                            -566,
                            247
                        ],
                        [
                            -567,
                            62
                        ],
                        [
                            -683,
                            63
                        ],
                        [
                            -685,
                            248
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_158",
            "properties": {
                "name": "Elevator_2",
                "description": "Elevator of floor 2"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -688,
                            -64
                        ],
                        [
                            -546,
                            -64
                        ],
                        [
                            -547,
                            -186
                        ],
                        [
                            -688,
                            -185
                        ],
                        [
                            -688,
                            -64
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_182",
            "properties": {
                "name": "A.203",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -560,
                            249
                        ],
                        [
                            -383,
                            248
                        ],
                        [
                            -382,
                            61
                        ],
                        [
                            -561,
                            61
                        ],
                        [
                            -560,
                            249
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_204",
            "properties": {
                "name": "A.204",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -378,
                            248
                        ],
                        [
                            -198,
                            247
                        ],
                        [
                            -198,
                            63
                        ],
                        [
                            -377,
                            62
                        ],
                        [
                            -378,
                            248
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_228",
            "properties": {
                "name": "A.205",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -192,
                            249
                        ],
                        [
                            -1,
                            247
                        ],
                        [
                            -1,
                            62
                        ],
                        [
                            -193,
                            61
                        ],
                        [
                            -192,
                            249
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_250",
            "properties": {
                "name": "A.206",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            3,
                            248
                        ],
                        [
                            267,
                            248
                        ],
                        [
                            267,
                            62
                        ],
                        [
                            4,
                            62
                        ],
                        [
                            3,
                            248
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_274",
            "properties": {
                "name": "A.207",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            270,
                            249
                        ],
                        [
                            566,
                            248
                        ],
                        [
                            566,
                            62
                        ],
                        [
                            272,
                            62
                        ],
                        [
                            270,
                            249
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_298",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            571,
                            249
                        ],
                        [
                            671,
                            247
                        ],
                        [
                            671,
                            63
                        ],
                        [
                            571,
                            59
                        ],
                        [
                            571,
                            249
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_315",
            "properties": {
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            719,
                            294
                        ],
                        [
                            719,
                            293
                        ],
                        [
                            719,
                            293
                        ],
                        [
                            719,
                            294
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_341",
            "properties": {
                "name": "A.208",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            831,
                            213
                        ],
                        [
                            1084,
                            214
                        ],
                        [
                            1084,
                            -180
                        ],
                        [
                            831,
                            -181
                        ],
                        [
                            831,
                            213
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_368",
            "properties": {
                "name": "Stair_2",
                "description": "Stair of Floor 2"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            669,
                            -190
                        ],
                        [
                            750,
                            -192
                        ],
                        [
                            749,
                            -190
                        ],
                        [
                            748,
                            -263
                        ],
                        [
                            672,
                            -263
                        ],
                        [
                            669,
                            -190
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_390",
            "properties": {
                "name": "Elevator_2",
                "description": "Elevator of floor 2"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            526,
                            -64
                        ],
                        [
                            671,
                            -65
                        ],
                        [
                            671,
                            -179
                        ],
                        [
                            525,
                            -180
                        ],
                        [
                            526,
                            -64
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_414",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            335,
                            -65
                        ],
                        [
                            519,
                            -66
                        ],
                        [
                            522,
                            -181
                        ],
                        [
                            336,
                            -183
                        ],
                        [
                            335,
                            -65
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_436",
            "properties": {
                "name": "Technical Services",
                "description": "supplying the technical devices"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            106,
                            -64
                        ],
                        [
                            331,
                            -67
                        ],
                        [
                            332,
                            -175
                        ],
                        [
                            107,
                            -179
                        ],
                        [
                            106,
                            -64
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_460",
            "properties": {
                "name": "Students affair",
                "description": "provide students with acedemic settings resolutions"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -542,
                            -64
                        ],
                        [
                            -341,
                            -65
                        ],
                        [
                            -339,
                            -186
                        ],
                        [
                            -542,
                            -187
                        ],
                        [
                            -542,
                            -64
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_482",
            "properties": {
                "name": "Stair_2",
                "description": "Stair of Floor 2"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -754,
                            -190
                        ],
                        [
                            -690,
                            -190
                        ],
                        [
                            -691,
                            -264
                        ],
                        [
                            -753,
                            -265
                        ],
                        [
                            -754,
                            -190
                        ]
                    ]
                ]
            }
        }
    ]
}
geojson = new OpenLayers.Format.GeoJSON();
vectors = new OpenLayers.Layer.Vector();
selectControl= new OpenLayers.Control.SelectFeature(vectors,
    {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addLayer(vectors);
vectors.addFeatures(geojson.read(featurecollection));
map.addControl(selectControl);
selectControl.activate();
function onPopupClose(){selectControl.unselect(selectedFeature);};
function onFeatureSelect(feature){
    selectedFeature = feature;
    popup = new OpenLayers.Popup.FramedCloud(feature.id + "pop", feature.geometry.getBounds().getCenterLonLat(),null,"<div style='font-size:.8em'>Room: " + feature.attributes.name + "<br />Description: " + feature.attributes.description + "</div>",null, true, onPopupClose);
    feature.popup = popup;
    map.addPopup(popup);
}
function onFeatureUnselect(feature){
    map.removePopup(feature.popup);
    feature.popup.destroy();
    feature.popup = null;
}
